import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';
var Api;
(function (Api) {
    Api["list"] = "/sys/user/list";
    Api["save"] = "/sys/user/add";
    Api["edit"] = "/sys/user/edit";
    Api["agentSave"] = "/sys/sysUserAgent/add";
    Api["agentEdit"] = "/sys/sysUserAgent/edit";
    Api["getUserRole"] = "/sys/user/queryUserRole";
    Api["duplicateCheck"] = "/sys/duplicate/check";
    Api["deleteUser"] = "/sys/user/delete";
    Api["deleteBatch"] = "/sys/user/deleteBatch";
    Api["importExcel"] = "/sys/user/importExcel";
    Api["exportXls"] = "/sys/user/exportXls";
    Api["recycleBinList"] = "/sys/user/recycleBin";
    Api["putRecycleBin"] = "/sys/user/putRecycleBin";
    Api["deleteRecycleBin"] = "/sys/user/deleteRecycleBin";
    Api["allRolesList"] = "/sys/role/queryall";
    Api["allTenantList"] = "/sys/tenant/queryList";
    Api["allPostList"] = "/sys/position/list";
    Api["userDepartList"] = "/sys/user/userDepartList";
    Api["changePassword"] = "/sys/user/changePassword";
    Api["frozenBatch"] = "/sys/user/frozenBatch";
    Api["getUserAgent"] = "/sys/sysUserAgent/queryByUserName";
    Api["syncUser"] = "/act/process/extActProcess/doSyncUser";
    Api["getCurrentUserBusiness"] = "/sys/user/getCurrentUserBusiness";
    Api["selectBusiness"] = "/sys/selectBusiness";
    Api["getCurrentUserCompany"] = "/sys/user/getCurrentUserCompany";
    Api["selectCompany"] = "/sys/selectCompany";
    Api["selectBusinessAndCompany"] = "/sys/selectBusinessAndCompany";
})(Api || (Api = {}));
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;
/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) => defHttp.get({ url: Api.list, params });
/**
 * 用户角色接口
 * @param params
 */
export const getUserRoles = (params) => defHttp.get({ url: Api.getUserRole, params }, { errorMessageMode: 'none' });
/**
 * 删除用户
 */
export const deleteUser = (params, handleSuccess) => {
    return defHttp.delete({ url: Api.deleteUser, params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
    });
};
/**
 * 批量删除用户
 * @param params
 */
export const batchDeleteUser = (params, handleSuccess) => {
    Modal.confirm({
        title: '确认删除',
        content: '是否删除选中数据',
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
            return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
                handleSuccess();
            });
        },
    });
};
/**
 * 保存或者更新用户
 * @param params
 */
export const saveOrUpdateUser = (params, isUpdate) => {
    let url = isUpdate ? Api.edit : Api.save;
    return defHttp.post({ url: url, params });
};
/**
 * 唯一校验
 * @param params
 */
export const duplicateCheck = (params) => defHttp.get({ url: Api.duplicateCheck, params }, { isTransformResponse: false });
/**
 * 获取全部角色
 * @param params
 */
export const getAllRolesList = (params) => defHttp.get({ url: Api.allRolesList, params });
/**
 * 获取全部租户
 */
export const getAllTenantList = (params) => defHttp.get({ url: Api.allTenantList, params });
/**
 * 获取指定用户负责部门
 */
export const getUserDepartList = (params) => defHttp.get({ url: Api.userDepartList, params }, { successMessageMode: 'none' });
/**
 * 获取全部职务
 */
export const getAllPostList = (params) => {
    return new Promise((resolve) => {
        defHttp.get({ url: Api.allPostList, params }).then((res) => {
            resolve(res.records);
        });
    });
};
/**
 * 回收站列表
 * @param params
 */
export const getRecycleBinList = (params) => defHttp.get({ url: Api.recycleBinList, params });
/**
 * 回收站还原
 * @param params
 */
export const putRecycleBin = (params, handleSuccess) => {
    return defHttp.put({ url: Api.putRecycleBin, params }).then(() => {
        handleSuccess();
    });
};
/**
 * 回收站删除
 * @param params
 */
export const deleteRecycleBin = (params, handleSuccess) => {
    return defHttp.delete({ url: Api.deleteRecycleBin, params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
    });
};
/**
 * 修改密码
 * @param params
 */
export const changePassword = (params) => {
    return defHttp.put({ url: Api.changePassword, params });
};
/**
 * 冻结解冻
 * @param params
 */
export const frozenBatch = (params, handleSuccess) => {
    return defHttp.put({ url: Api.frozenBatch, params }).then(() => {
        handleSuccess();
    });
};
/**
 * 获取用户代理
 * @param params
 */
export const getUserAgent = (params) => defHttp.get({ url: Api.getUserAgent, params }, { isTransformResponse: false });
/**
 * 保存或者更新用户代理
 * @param params
 */
export const saveOrUpdateAgent = (params) => {
    let url = params.id ? Api.agentEdit : Api.agentSave;
    return defHttp.post({ url: url, params });
};
/**
 * 用户同步流程
 * @param params
 */
export const syncUser = () => defHttp.put({ url: Api.syncUser });
/**
 * 获取登录用户商户信息
 */
export const getCurrentUserBusiness = (params) => defHttp.get({ url: Api.getCurrentUserBusiness, params });
/**
 * 切换选择商户
 */
export const selectBusiness = (params) => defHttp.put({ url: Api.selectBusiness, params });
/**
 * 获取登录用户公司信息
 */
export const getCurrentUserCompany = (params) => defHttp.get({ url: Api.getCurrentUserCompany, params });
/**
 * 切换选择公司
 */
export const selectCompany = (params) => defHttp.put({ url: Api.selectCompany, params });
/**
 * 切换选择商户和公司
 */
export const selectBusinessAndCompany = (params) => defHttp.put({ url: Api.selectBusinessAndCompany, params });
